namespace hjc {
	export class Camera extends SingComp {

		private $map: egret.DisplayObjectContainer;
		private $aoiW: number;
		private $aoiH: number;
		private $sqaure: egret.Shape;
		public get aoiW(): number { return this.$aoiW; }
		public get aoiH(): number { return this.$aoiH; }
		public get map(): egret.DisplayObjectContainer { return this.$map; }
		public init(eneity: hjc.Entity, map: egret.DisplayObjectContainer) {
			this.$entity = eneity;
			this.$map = map;
			this.setAoiSquare(game.width, game.height);
		}

		public setAoiSquare(aoiW: number, aoiH: number) {
			this.$aoiW = aoiW;
			this.$aoiH = aoiH;
			this.$sqaure = ui.drawRect({
				width: this.$aoiW, height: this.$aoiH, centered: true,
				lineColor: Color.GREEN, thickness: 3, lineDash: true, fillAlpha: 0,
			}, this.$sqaure);
			this.$sqaure.name = '九屏范围';
		}

		public showAoi(show: boolean, container?: egret.DisplayObjectContainer): void {
			if (show && !!container) {
				this.entity.sprite.views.pushUnique(this.$sqaure)
				container.addChild(this.$sqaure);
			} else this.$sqaure.visible = false;
		}
	}
}